<template>
	<view class="repair-wrap">
		<!-- <viewData :type="'noData'" :nextPage="!nextPage" :isTab="false" :isData="listData.length < 1" :loading="loading"
				  @onRefresh="onRefresh"> -->
		<view
			style="width: 100%;border: 1px solid rgb(245, 245, 245);background: rgb(255, 255, 255);z-index: 15;position: fixed;">
			<view style="margin: 0 auto;">

				<!-- <view class="search">
					<view class="u-flex-1 u-m-r-10 ">
						<u-input style='text-indent: 30rpx;border-radius: 26px;border: 1px solid #427705;'
							v-model="nameSere" placeholder='请输入员工姓名编号' />
					</view>

					<view @click="getList">搜索</view>
				</view> -->

				<!-- <view class="search">
					<input class="search-input" v-model="nameSere" placeholder='请输入员工姓名编号' />
					<view class="btn">
						<text style="color: #FFFFFF;" @click="getList">搜索</text>
					</view>
				</view> -->
				<view class="search">
					<input class="search-input" v-model="nameSere" placeholder='请输入员工姓名编号' />
					<view class="btn" @click="getList">
						<text style="color: #FFFFFF;">搜索</text>
					</view>
				</view>

			</view>
		</view>
		<view style="padding-top: 49px;">
			<view class="u-m-t-10 repair-box" style="padding:0 10px " v-for="(item,index) in personnelList">
				<view class="bg-white p-4 shadow rounded-2">
					<view style="display: flex;">
						<view>
							<image @click="preview(item.employee_logo)" style="width: 100px;height: 110px;"
								:src="item.employee_logo ||'https://clhy-img.oss-cn-beijing.aliyuncs.com/logo/avatar.jpg'"
								mode="aspectFill"></image>
							<view class="staff-abous">
								<view class="staff-abous-text">{{item.employee_name}}</view>
							</view>
						</view>
						<view style="margin-left: 25px;">
							<view class="repair-titel u-m-b-20">
								<view style="display: flex;">
									<h3>{{item.orgName}}</h3>
								</view>
							</view>
							<view style="color: #999;">
								<view>项目：<span
										style="color: #333;font-weight: 550;">{{item.employee_project_name}}</span>
								</view>
							</view>

							<view style="color: #999999;margin-top: 12px;">
								<view>部门：<span style="color: #333;">{{item.employee_org_dept_name}}</span></view>
							</view>
							<view style="color: #999999;margin-top: 12px;"
								@click="handlePost(item.employee_org_post_id)">
								<view>岗位：<span style="color: #0000ff;">{{item.employee_org_post_name}}</span></view>
							</view>
							<view style="color: #999999;margin-top: 12px;">
								<view>编号：<span style="color: #333;">{{item.employee_code}}</span></view>
							</view>

						</view>

					</view>
					<view style="margin-top: -23px;display: flex;">
						<view style="font-weight: 550;">格言：</view>
						<view style="color: #333;">{{item.employee_motto ? item.employee_motto : '这家伙很懒，什么也没写！'}}</view>
					</view>
				</view>


			</view>
		</view>
		<!-- </viewData> -->

		<!-- 提交弹窗 -->
		<view class="modal" v-if="submission">
			<view class="modal-cont">
				<view class="modal-title" style="margin-top: 18px;">
					岗位职责详情
				</view>

				<view style="padding: 10px 20px;margin-top: 7px;">
					<view>
						<image style="width: 34px;height: 28px;" src="../../static/image/post.png" mode=""></image>

					</view>
					<view style="text-align: center;margin-top: -26px;">
						{{postDutyData.dept_name}}-{{postDutyData.post_name}}职责
					</view>
				</view>
				<view style="padding: 10px 20px;height: 319px;margin-top: 10px;">
					<view style="letter-spacing: 1.5px;height: 290px;overflow: auto;">
						<span v-if="postDutyData.post_duty "
							style="margin-left: 10px;margin-left: 34px;">{{ postDutyData.post_duty }}</span>
						<view class="" v-else style="display: flex;flex-direction: column;align-items: center;">
							<image style="width: 400rpx;margin-bottom: 50rpx;" src="../../static/image/zanwushuju.png"
								mode=""></image>
							<view class="">
								暂无职责数据
							</view>
						</view>
					</view>
				</view>

				<view class="modal-bottom">
					<view class="btn-cancel1" @click="submission = false">关闭</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				personnelList: [],
				pageIndex: 1,
				loading: false,
				// type: 1,
				nextPage: false,
				listData: [],
				curPage: 1,
				//搜索条件
				searchForm: {
					employeeName: "",
					employeePostProperties: "",
					employeeSex: "",
					companyId: "",
					projectId: "",
					departId: "",
					postId: "",
					startAge: "",
					endAge: "",
				},
				postDutyData: {},
				submission: false,
				nameSere: null,
			}
		},
		onShow() {
			let _this = this
			if (uni.getStorageSync('phone')) {
				if (uni.getStorageSync('loginFlag')) {
					if (!uni.getStorageSync('hourseList')) {
						uni.showModal({
							title: '请先进行业主认证',
							showCancel: false,
							confirmText: '确认',
							confirmColor: '#F9A832',
							success: function(res) {
								if (res.confirm) {
									_this.$Router.push({
										path: '/pages/address/address'
									})
								}
							}
						});
						this.$openInvite()
					} else {
						_this.showFlag = true
						_this.homelist = uni.getStorageSync('hourseList')[uni.getStorageSync('hourseNum') || 0]
						_this.name = _this.homelist.proName;
						_this.address = _this.homelist.buildDistrictCode + '-' + _this.homelist.buildTowerCode + '-' +
							_this.homelist.roomUnitNumber + '-' + _this.homelist.roomCode
						_this.getList()
					}
				} else {
					uni.showModal({
						title: '请先实名认证',
						showCancel: false,
						confirmText: '确认',
						confirmColor: '#F9A832',
						success: function(res) {
							if (res.confirm) {
								_this.$Router.push({
									path: '/pages/realName/realName'
								})
							}
						}
					});
				}
			} else {
				uni.showModal({
					title: '请先登录',
					showCancel: false,
					confirmText: '确认',
					confirmColor: '#F9A832',
					success: function(res) {
						if (res.confirm) {
							console.log('a')
							_this.$Router.pushTab({
								path: '/pages/user/user'
							})
						}
					}
				});
			}
			// this.getList()
		},
		// onLoad() {
		// 	this.getList()
		// },
		onPullDownRefresh() {
			this.getList()
		},
		methods: {
			handlePost(id) {
				this.$request.api.getPost({
					post_id: id
				}).then(res => {
					this.postDutyData = res.data.data
					this.submission = true
				})
			},
			// onRefresh() {
			// 	if (!this.nextPage) {
			// 		this.curPage = this.curPage + 1;
			// 		// this.getList();
			// 	}
			// },
			// 获取列表
			getList() {
				if (this.curPage < 2) {
					uni.showLoading({
						title: '加载中'
					});
				}
				this.$request.api.getpersonnellist({
					// project_id:uni.getStorageSync('projectitem')[uni.getStorageSync('hourseNum')].proId,
					project_id: uni.getStorageSync('projectItem').proId,
					name: this.nameSere
				}).then(res => {
					if (this.curPage == 1) {
						this.personnelList = res.data.data.datalist || [];
					} else {
						this.personnelList = [...this.personnelList, ...res.data.data.datalist];
					}
					console.log(this.personnelList)
					this.nextPage = res.data.data.isEndPage
					this.loading = true;
					uni.hideLoading();
					// this.personnelList = res.data.data.datalist
					// console.log(this.personnelList)
					uni.stopPullDownRefresh()
				})
			},
			// 图片预览
			preview(item) {
				uni.previewImage({
					urls: [item],
					current: 0,
					longPressActions: {
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			},
			// datails(id) {
			// 	uni.navigateTo({
			// 		url: '/pages/publicity/detailspublicity?id='+id
			// 	})
			// },
			// datails() {
			// 	uni.navigateTo({
			// 		url: '/pages/authentication/datails'
			// 	})
			// },
		}
	}
</script>

<style lang="scss">
	.staff-abous {
		// position: absolute;
		width: 100%;
		height: 36px;
		// bottom: 0;
		// left: 0;
		// background:rgb(0 0 0 / 37%);
		text-align: center;
		line-height: 34px;
		color: #fff;
		font-weight: 600;
		z-index: 5;
		position: relative;
		top: -39px;
		background: #3535359c;
	}

	.staff-abous-text {
		width: 60px;
		margin: auto;
		text-align: justify;
		-moz-text-align-last: justify;
		text-align-last: justify;
		font-family: 'Kaiti', '楷体-简';
		font-size: 18px;
	}

	.repair-wrap {
		// width: 100%;
		// min-height: 100vh;
		height: auto;
		background: #f4f4f4;
		overflow: hidden;

		.repair-box {
			// background: #fff;

			.repair-titel {
				// height: 44rpx;
				// line-height: 44rpx;

				.repair-titel-l {
					float: left;
				}

				.repair-titel-r {
					float: right;
					color: #999;
				}
			}

			.repair-6 {
				color: #666;
			}
		}
	}

	.repair-titel i {
		width: 6px;
		height: 13px;
		background: linear-gradient(180deg, #76D904 0%, #417505 100%);
		border-radius: 4px;
		display: inline-block;
		vertical-align: middle;
		margin-top: 4px;
	}

	.search {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
		color: #3d7fff;
		height: 100rpx;
		border-bottom: 1rpx solid #eeeeee;
		width: 100%;
		padding-left: 27px;
		padding-right: 31px;
		// position: fixed;
		z-index: 20;
		background: #FFFFFF;
	
		.search-clear {
			width: 36rpx;
			height: 36rpx;
			position: absolute;
			left: 271px;
			top: 50%;
			transform: translateY(-50%);
		}
	
		.search-input {
			width: 312px;
			height: 66rpx;
			background: #f0f2f5;
			border-radius: 33rpx;
			line-height: 66rpx;
			font-size: 13px;
			padding: 0 33rpx;
			color: #333333;
			box-sizing: border-box;
		}
	
		.btn {
			width: 21%;
			line-height: 33px;
			// border: 1px solid red;
			border: 1px solid linear-gradient(180deg, #76D904 0%, #417505 100%);
			border-radius: 18px;
			text-align: center;
			margin-left: -43px;
			background: linear-gradient(180deg, #76D904 0%, #417505 100%);
		}
	}

	.modal {
		position: fixed;
		top: 6%;
		left: 0%;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.8);
		z-index: 10;
	}

	.modal-cont {
		width: 610rpx;
		// min-height: 420rpx;
		background: #ffffff;
		box-shadow: 0rpx 6rpx 12rpx 0rpx rgba(0, 0, 0, 0.12);
		border-radius: 24rpx;
		display: flex;
		flex-direction: column;

		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
	}

	.modal-icon {
		width: 80rpx;
		height: 80rpx;
		margin-top: 67rpx;

	}

	.modal-title {
		font-size: 32rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 600;
		color: #333333;
		line-height: 45rpx;
		margin-top: 22rpx;
		align-items: center;
		border-bottom: 1px solid #ddd;
		padding: 0px 20px 10px;
		text-align: center;
		width: 89%;
		margin: auto;
	}

	.modal-bottom {
		width: 89%;
		height: 84rpx;
		border-top: 1rpx solid #e6e9ed;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 50rpx;
		margin: auto;
	}

	.btn-cancel1 {
		width: 100%;
		height: 84rpx;
		text-align: center;
		line-height: 84rpx;
		/* border-right: 1rpx solid #d8d8d8; */
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		box-sizing: border-box;
	}

	.search {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
		color: #3d7fff;
		height: 100rpx;
		border-bottom: 1rpx solid #eeeeee;
		width: 100%;
		padding-left: 27px;
		padding-right: 31px;
		// position: fixed;
		z-index: 20;
		background: #FFFFFF;

		.search-clear {
			width: 36rpx;
			height: 36rpx;
			position: absolute;
			left: 271px;
			top: 50%;
			transform: translateY(-50%);
		}

		.search-input {
			width: 312px;
			height: 66rpx;
			background: #f0f2f5;
			border-radius: 33rpx;
			line-height: 66rpx;
			font-size: 13px;
			padding: 0 33rpx;
			color: #333333;
			box-sizing: border-box;
		}

		.btn {
			width: 21%;
			line-height: 33px;
			// border: 1px solid red;
			border: 1px solid linear-gradient(180deg, #76D904 0%, #417505 100%);
			border-radius: 18px;
			text-align: center;
			margin-left: -43px;
			background: linear-gradient(180deg, #76D904 0%, #417505 100%);
		}
	}
</style>